<!--<h1>Jugadores del Equipo</h1>-->
<table class="players-table">
	<tr>
		<th colspan="3" align="left">
		<h1>Jugadores del Equipo</h1>
		</th>
	</tr>
	<?php
		foreach($scores as $row) {
	?>
	<tr>
		<td>
		<strong>
		<?php echo $row['player_name'];?>
		</strong>
		</td>
		<td>
		<a class="ui-avena-button ui-state-default ui-corner-all" href="/index.php/players/playerinfo/<?php echo $row['id'];?>">
		<span class="ui-icon ui-icon-contact"></span>
		Ver Ficha
		</a>
		</td>
		<td>
		<a id="<?php echo $row['id'];?>" class="ui-state-default ui-corner-all delete-player-button ui-avena-button" href="#">
		<span class="ui-icon ui-icon-closethick"></span>Remover
		</a>
		</td>
	</tr>
	<?php
	}
	?>
</table>

<script>
	$('.delete-player-button').click( function() {
		//alert("delete player clicked");
		//alert("delete player clicked");
		var id_clicked = $(this).attr("id");
		var team_id = $('#team_id').val();
		var $dialog = $('<div></div>')
		.html('Desea remover este jugador del equipo?')
		.dialog({
			autoOpen: false,
			title: 'Confirme operaci&oacute;n',
			buttons: {
				"Si": function() {
					$(this).dialog("close");
					//alert(id_clicked+"+"+$('#team_id').val());

					$.post("/index.php/teams/removePlayerFromTeam", {
						'team_id': $('#team_id').val(),
						'player_id' : id_clicked
					}, function() {

						$("#team-players-div").load("/index.php/teams/playerListingAJAX/"+team_id);
						$("#non-players-div").load("/index.php/teams/nonPlayerListingAJAX/"+team_id);

					});
					//alert("Jugadores Agregados!")
				},
				"No": function() {
					$(this).dialog("close");
				}
			}

		});

		$dialog.dialog('open');

		return false;
	});
</script>